package com.nowadays.mobile.mvp.presenter;

import com.nowadays.mobile.mvp.model.MainInteractor;
import com.nowadays.mobile.mvp.model.MainInteractorImpl;
import com.nowadays.mobile.mvp.presenter.executor.MainThread;
import com.nowadays.mobile.mvp.presenter.executor.MainThreadImpl;
import com.nowadays.mobile.mvp.view.SettingView;
import com.nowadays.mobile.utils.SettingInfo;

public class SettingPresenterImpl implements SettingPresenter {
  private MainInteractor mainInteractor;
  private SettingView mView;

  public SettingPresenterImpl(SettingView mView) {
    MainThread mainThread = MainThreadImpl.getInstance();
    this.mView = mView;
    this.mainInteractor = new MainInteractorImpl(mainThread);
  }

  @Override
  public void updateFocus() {
    this.mainInteractor.initFocus();
  }

  @Override
  public void onStart() {

  }

  @Override
  public void onRestart() {

  }

  @Override
  public void onResume() {
    SettingInfo settingInfo = SettingInfo.getInstance();
    boolean isPrevent = settingInfo.getIsPreventLockScreen();
    if (isPrevent) {
      mView.preventLockScreen(isPrevent);
    }
  }

  @Override
  public void onPause() {
    SettingInfo settingInfo = SettingInfo.getInstance();
    boolean isPrevent = settingInfo.getIsPreventLockScreen();
    if (isPrevent) {
      mView.preventLockScreen(!isPrevent);
    }
  }

  @Override
  public void onStop() {

  }

  @Override
  public void onDestroy() {
    mView = null;
  }
}
